package io.renren.modules.medical.controller;

import io.renren.common.result.Result;
import io.renren.modules.medical.entity.PatientInfoEntity;
import io.renren.modules.medical.service.PatientInfoService;
import io.renren.modules.medical.vo.medicalVo.PatientTreeVo;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 病人信息接口
 * @author Luo Sheng
 * @school YiBin university
 * @create 2023-03-23 17:00
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/medical/patientinfo")
public class PatientInfoController {

    private final PatientInfoService patientInfoService;

    /**
     * 获取到病情分类树（添加信息）
     */
    @RequiresPermissions("patientinfo:tree")
    @GetMapping("/tree")
    public Result<List<PatientTreeVo>> patientTree(){
        List<PatientTreeVo> resultList = patientInfoService.patientTree();
        return Result.success(resultList);
    }

    @GetMapping("getPatients/{subId}")
    public Result<List<PatientInfoEntity>> getPatients(@PathVariable("subId") Long subId){
        // 获取到患者集合
        List<PatientInfoEntity> patients = patientInfoService.getPatients(subId);
        return Result.success(patients);
    }

    @GetMapping("info/{id}")
    public Result<PatientInfoEntity> info(@PathVariable("id") Long id){
        return Result.success(patientInfoService.getById(id));
    }

}
